﻿    var openQuestion;
    var curA =document.documentElement;
    function onPageLoad()
    {
        questions = document.getElementsByTagName('a');
        for (curAId = 0; curAId < questions.length; curAId++)
        {
            curA = questions[curAId];
            if (curA.className =="question")
            {
                curA.onclick = questionClick;
            }
        }
      hideAllAnswers();
    }
    
    function questionClick(event)
    {
        event = (event) ? event : window.event;
        myQuestion = (event.target)? event.target : event.srcElement;
        questionParent = myQuestion.parentNode;
        spansInParent = questionParent.getElementsByTagName('div')
        for (curSpanId = 0; curSpanId < spansInParent.length; curSpanId++)
        {
            curSpanInParent = spansInParent[curSpanId];
             if( curSpanInParent.className == "answer")
                {
                    if(openQuestion != null)
                    {
                        if(curSpanInParent.innerHTML == openQuestion.innerHTML)
                        {
                            openQuestion.style.display= 'none';
                            openQuestion = null;
                            showTutorialText()
                        }
                        else
                        {
                            hideAllAnswers();
                            curSpanInParent.style.display = 'block';
                            openQuestion = curSpanInParent;
                            hideTutorialText();
                        }
                    }
                    else
                    {
                        hideAllAnswers();
                        curSpanInParent.style.display = 'block';
                        openQuestion = curSpanInParent;
                        hideTutorialText();
                    }
                
                }
        
 
        }
        
    }
    
    function hideAllAnswers()
    {
        answers = document.getElementsByTagName('div');
        for (curSpanId = 0; curSpanId < answers.length; curSpanId++)
        {
            curSpan = answers[curSpanId];
            if (curSpan.className =="answer")
            {
               curSpan.style.display='none';
            }
        }
    }

 function showTutorialText()
    {
        myText = document.getElementById("tutorialText");
        if( myText != null)
        {
            myText.style.visibility  = 'visible';
        }
    }
    
    
    function hideTutorialText()
    {
        myText = document.getElementById("tutorialText");
        if( myText != null)
        {
            myText.style.visibility  = 'hidden';
        }
    }
